package com.demo;

public class ArrayDemo {
    public static void main(String[] args) {
        //定义一个动态数组初始化
        int[] arr1 = {29,13,48,20,88,10,7,99};

        ArrSort(arr1);

        printArr(arr1);
    }

    /**
     * 方法参数定义
     * @param arr1
     */
    public static void ArrSort(int[] arr1){
        if(arr1 .length<=0){
            System.out.println("什么玩意");
        }

        for(int x=0;x<arr1.length-1;x++){
            for(int y = 0;y<arr1.length-1-x;y++){
                if(arr1[y] > arr1[y+1]){
                    int tmp = arr1[y];
                    arr1[y] = arr1[y+1];
                    arr1[y+1] = tmp;
                }
            }
        }
    }

    /**
     * @desc  答应输出数组的内容
     * @param arr
     */
    public static void printArr(int[] arr){
        if(arr.length<=0){
            System.out.println("数组空的哦");
            return;
        }
        System.out.print("[");
        for(int i=0;i<arr.length;i++){
            if(i<arr.length-1){
                System.out.print(arr[i]+", ");
            }else{
                System.out.print(arr[i]);
            }
        }
        System.out.println("];");
    }
}
